/**
 * Form Layout by Dagny.
 * Functional coding by Dagny.
 */

package Forms;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;

import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

import Classes.Agents;
import Classes.Validate;
import teComponents.*;
import Classes.Agencies;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class AgenciesForm  extends teComponents.teJinternalFrame 
{
	//private properties
	private teJList lstAll;
	private teJButton btnGo;
	private teJLabel lblsearchProvince;
	private teJComboBox cbosearchCity;
	private teJLabel lblsearchCity;
	private teJPanel pnlSearch;
	private teJLabel lblSelectedPanel;
	private teJLabel lblAgencyId;
	private teJTextField txtAgencyId;
	private teJLabel lblAddress;
	private teJTextField txtAddress;
	private JPanel pnlSelected;
	private teJButton btnAdd;
	private JScrollPane jScrollPane1;
	private teJLabel lblsearchCountry;
	private teJComboBox cbosearchCountry;
	private teJComboBox cbosearchProvince;
	private teJTextField txtFax;
	private teJLabel lblPostal;
	private teJTextField txtPostal;
	private teJLabel lblProvince;
	private teJTextField txtProvince;
	private teJLabel lblCity;
	private teJTextField txtCity;
	private teJLabel lblFax;
	private teJButton btnUpdate;
	private teJButton btnClear;
	private teJButton btnDelete;
	private teJLabel lblSearch;
	private teJLabel lblAll;
	private teJLabel lblPhone;
	private teJTextField txtAgtBusPhone;
	private teJLabel lblCountry;
	private teJTextField txtCountry;	
	//create generic Agencies
	private Agencies genericAgency = new Agencies();
	
	//main just to view the form and test it
	//comment out once we have it joined with the rest of the application
	public static void main(String[] args) 
	{
		SwingUtilities.invokeLater(new Runnable() 
		{
			public void run() 
			{
				AgenciesForm inst = new AgenciesForm();
				//inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	//public constructor
	public AgenciesForm() 
	{
		super();
		//load the GUI builder
		initGUI();

	}
	
	//GUI builder
	private void initGUI() 
	{
		//default to enter into combo boxes until the refresh happens at the end of the GUI creation:
		String[] defaultComboBoxString = {"choice"};
		ComboBoxModel cboDefaultLoad = 
			new DefaultComboBoxModel(defaultComboBoxString);
		
		try {
			{
				this.setTitle("Maintain Agencies");
				{
					jScrollPane1 = new JScrollPane();
					getContentPane().add(jScrollPane1);
					jScrollPane1.setBounds(12, 47, 455, 242);
					{
						lstAll = new teJList();
						jScrollPane1.setViewportView(lstAll);
						refreshAgenciesList();
						lstAll.setBounds(12, 47, 455, 242);
						lstAll.addListSelectionListener(new ListSelectionListener() 
						{
							
							@Override
							public void valueChanged(ListSelectionEvent e) 
							{
								//if the selection is not null
								if (lstAll.getSelectedIndex() != -1)
								{
									//when the selection in the list box changes, populate the 
									//information for the agency in the Your Selection Panel
									//first create a new agency to hold the information
									Agencies selectedAgency = (Agencies)lstAll.getSelectedValue();
									//then grab the agency id from that new agency
									int agencyid = selectedAgency.getAgencyId();
									// using the loadAgencyInformation function in Agencies,
									selectedAgency.loadAgencyInformation(agencyid);
									ArrayList<String> agencyInfo = selectedAgency.loadAgencyInformation(agencyid);
									//grab each element of the agencyInfo array and put it into the various fields:
									txtAgencyId.setText((String)(agencyInfo.get(0)));
									txtAddress.setText(agencyInfo.get(1));
									txtCity.setText(agencyInfo.get(2));
									txtProvince.setText(agencyInfo.get(3));
									txtPostal.setText(agencyInfo.get(4));
									txtCountry.setText(agencyInfo.get(5));
									
									//get the phone and fax numbers from the database:
									String unformattedPhone = agencyInfo.get(6);
									String unformattedFax = agencyInfo.get(7);
									
									//format the phone
									String phone = "(" + unformattedPhone.substring(0, 3) + 
													") " + unformattedPhone.substring(3, 6) + "-" + unformattedPhone.substring(6);
									//format the fax
									String fax = "(" + unformattedFax.substring(0, 3) + 
													") " + unformattedFax.substring(3, 6) + "-" + unformattedFax.substring(6);
									
									//put the formatted versions into the proper text fields:
									txtAgtBusPhone.setText(phone);
									txtFax.setText(fax);
									
									
									//disable the Add button, the Search button and the Agency ID field
									btnAdd.setEnabled(false);
									btnGo.setEnabled(false);
									txtAgencyId.setEditable(false);
									//enable the Update and Delete Buttons
									btnDelete.setEnabled(true);
									btnUpdate.setEnabled(true);
								}
							}
						});
					}
				}
			}
			{
				this.setSize(913, 367);
			}		
			{
				lblAll = new teJLabel();
				getContentPane().add(lblAll);
				lblAll.setText("Agents");
				lblAll.setBounds(12, 27, 80, 14);
				lblAll.setHorizontalAlignment(SwingConstants.LEFT);
			}
			{
				lblSearch = new teJLabel();
				getContentPane().add(lblSearch);
				lblSearch.setText("Search for: ");
				lblSearch.setBounds(483, 27, 110, 14);
				lblSearch.setHorizontalAlignment(SwingConstants.LEFT);
			}
			{
				btnAdd = new teJButton();
				getContentPane().add(btnAdd);
				btnAdd.setText("Add");
				btnAdd.setBounds(12, 301, 100, 25);
				btnAdd.setToolTipText("Add a new Agency to the database, based on the information in the 'Your Selection' form on the right.");
				btnAdd.addMouseListener(new MouseAdapter() 
				{
					public void mouseClicked(MouseEvent e)
					{
						if (validateAgencyForm())
						{
							//create an instance of Agency
							Agencies addAgency = new Agencies();
							
							int agencyid = addAgency.getNextNewAgecyId();
							String address = txtAddress.getText();
							String city = txtCity.getText();
							String prov = txtProvince.getText();
							String postal = txtPostal.getText();
							String country = txtCountry.getText();
							//phone and fax are stored in the agency table as digits only, no need to format,
							//but do need to strip formatting if it's something that has been displayed
							String phone = txtAgtBusPhone.getText().replaceAll("[^0-9]", "");
							String fax = txtFax.getText().replaceAll("[^0-9]", "");
							
							//call the add method from Agencies
							addAgency.addAgency(agencyid, address, city, prov, postal, country, phone, fax);
							
							//refresh the Agencies List Box
							refreshAgenciesList();
							
							//clear the Selection boxes
							clearSelectionPanel();
							
							//update the combo boxes
							refreshDropDownBoxes();
						}
					}
				});
			}
			{
				btnDelete = new teJButton();
				getContentPane().add(btnDelete);
				btnDelete.setText("Delete");
				btnDelete.setBounds(129, 301, 100, 25);
				btnDelete.setEnabled(false);
				btnDelete.setToolTipText("Delete the selected Agency from the database.");
				btnDelete.addMouseListener(new MouseAdapter() 
				{
					public void mouseClicked(MouseEvent e)
					{
						//create an instance of Agencies
						Agencies deleteAgency = new Agencies();
						
						int agencyid = Integer.parseInt(txtAgencyId.getText());

						//call the delete method from agencies
						deleteAgency.deleteAgency(agencyid);
						
						//refresh the agencies List Box
						refreshAgenciesList();
						
						//clear the Selection boxes
						clearSelectionPanel();

						//update the combo boxes
						refreshDropDownBoxes();
						
						//enable the add and search buttons again
						btnAdd.setEnabled(true);
						btnGo.setEnabled(true);
					}
				});
			}
			{
				btnClear = new teJButton();
				getContentPane().add(btnClear);
				btnClear.setText("Clear");
				btnClear.setBounds(365, 301, 100, 25);
				btnClear.setToolTipText("Clears all the information in the forms and refreshes the Agency list with all agencies in the database.");
				btnClear.addMouseListener(new MouseAdapter() 
				{
					public void mouseClicked(MouseEvent e)
					{
						//clear the list box
						lstAll.clearSelection();
						//reload the list box with all agencies
						refreshAgenciesList();
						
						//clear all the text boxes and combo boxes
						clearSelectionPanel();
						clearSearchPanel();
						
						//disable the add, delete and update buttons
						btnAdd.setEnabled(true);
						btnDelete.setEnabled(false);
						btnUpdate.setEnabled(false);
						btnGo.setEnabled(true);
					}
				});
			}
			{
				btnUpdate = new teJButton();
				getContentPane().add(btnUpdate);
				btnUpdate.setText("Update");
				btnUpdate.setBounds(247, 301, 100, 25);
				btnUpdate.setEnabled(false);
				btnUpdate.setToolTipText("Update the selected Agency in the database.");
				btnUpdate.addMouseListener(new MouseAdapter() 
				{
					public void mouseClicked(MouseEvent e)
					{
						if (validateAgencyForm())
						{
							//create an instance of Agency
							Agencies updateAgency = new Agencies();
							
							int agencyid = Integer.parseInt(txtAgencyId.getText());
							String address = txtAddress.getText();
							String city = txtCity.getText();
							String prov = txtProvince.getText();
							String postal = txtPostal.getText();
							String country = txtCountry.getText();
							//phone and fax are stored in the agency table as digits only, no need to format,
							//but do need to strip formatting if it's something that has been displayed
							String phone = txtAgtBusPhone.getText().replaceAll("[^0-9]", "");
							String fax = txtFax.getText().replaceAll("[^0-9]", "");
							
							//call the update method from Agencies
							updateAgency.updateAgency(agencyid, address, city, prov, postal, country, phone, fax);
							
							//refresh the Agencies List Box
							refreshAgenciesList();
							
							//clear the Selection boxes
							clearSelectionPanel();

							//update the combo boxes
							refreshDropDownBoxes();
							
							//enable the add and search buttons again
							btnAdd.setEnabled(true);
							btnGo.setEnabled(true);
						}
					}
				});
			}
			{
				pnlSelected = new teJPanel();
				getContentPane().add(pnlSelected);
				pnlSelected.setBounds(479, 190, 415, 136);
				pnlSelected.setLayout(null);
				{
					lblAddress = new teJLabel();
					pnlSelected.add(lblAddress);
					lblAddress.setText("Address:");
					lblAddress.setBounds(102, 13, 123, 14);
					lblAddress.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtAddress = new teJTextField();
					pnlSelected.add(txtAddress);
					txtAddress.setBounds(102, 27, 300, 18);
				}
				{
					txtAgencyId = new teJTextField();
					pnlSelected.add(txtAgencyId);
					txtAgencyId.setBounds(8, 27, 82, 18);
				}
				{
					lblAgencyId = new teJLabel();
					pnlSelected.add(lblAgencyId);
					lblAgencyId.setText("Agency ID:");
					lblAgencyId.setBounds(8, 13, 82, 14);
					lblAgencyId.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtAgtBusPhone = new teJTextField();
					pnlSelected.add(txtAgtBusPhone);
					txtAgtBusPhone.setBounds(144, 108, 122, 18);
				}
				{
					lblPhone = new teJLabel();
					pnlSelected.add(lblPhone);
					lblPhone.setText("Phone:");
					lblPhone.setBounds(144, 94, 49, 14);
					lblPhone.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtCountry = new teJTextField();
					pnlSelected.add(txtCountry);
					txtCountry.setBounds(9, 108, 122, 18);
				}
				{
					lblCountry = new teJLabel();
					pnlSelected.add(lblCountry);
					lblCountry.setText("Country:");
					lblCountry.setBounds(8, 94, 62, 14);
					lblCountry.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtCity = new teJTextField();
					pnlSelected.add(txtCity);
					txtCity.setBounds(8, 70, 214, 18);
				}
				{
					lblCity = new teJLabel();
					pnlSelected.add(lblCity);
					lblCity.setText("City:");
					lblCity.setBounds(8, 55, 76, 14);
					lblCity.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtProvince = new teJTextField();
					pnlSelected.add(txtProvince);
					txtProvince.setBounds(234, 70, 50, 18);
				}
				{
					lblProvince = new teJLabel();
					pnlSelected.add(lblProvince);
					lblProvince.setText("Prov:");
					lblProvince.setBounds(234, 55, 53, 14);
					lblProvince.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtPostal = new teJTextField();
					pnlSelected.add(txtPostal);
					txtPostal.setBounds(296, 70, 106, 18);
				}
				{
					lblPostal = new teJLabel();
					pnlSelected.add(lblPostal);
					lblPostal.setText("Postal Code:");
					lblPostal.setBounds(296, 55, 91, 14);
					lblPostal.setHorizontalAlignment(SwingConstants.LEFT);
				}
				{
					txtFax = new teJTextField();
					pnlSelected.add(txtFax);
					txtFax.setBounds(278, 108, 122, 18);
				}
				{
					lblFax = new teJLabel();
					pnlSelected.add(lblFax);
					lblFax.setText("Fax:");
					lblFax.setBounds(278, 94, 80, 14);
					lblFax.setHorizontalAlignment(SwingConstants.LEFT);
				}
			}
			{
				lblSelectedPanel = new teJLabel();
				getContentPane().add(lblSelectedPanel);
				lblSelectedPanel.setText("Your Selection:");
				lblSelectedPanel.setBounds(479, 172, 101, 14);
				lblSelectedPanel.setHorizontalAlignment(SwingConstants.LEFT);
			}
			{
				pnlSearch = new teJPanel();
				getContentPane().add(pnlSearch);
				pnlSearch.setBounds(483, 47, 415, 119);
				pnlSearch.setLayout(null);
				{
					btnGo = new teJButton();
					pnlSearch.add(btnGo);
					btnGo.setText("Search");
					btnGo.setBounds(320, 13, 88, 93);
					btnGo.setToolTipText("Searches the Agency table for agencies that match the parameters in the search panel.");
					btnGo.addMouseListener(new MouseAdapter() 
					{
						public void mouseClicked(MouseEvent e)
						{
							//clear the current list
							lstAll.clearSelection();
							
							//disable the add, delete and update buttons
							btnAdd.setEnabled(false);
							btnDelete.setEnabled(false);
							btnUpdate.setEnabled(false);
							
							//create the SQL statement to search with
							String searchSQL = "SELECT * FROM agencies WHERE (1 = 1) ";
							//check to see if any of the other parameters are there
							if (cbosearchCity.getSelectedItem().toString() != "--Select a City--")
							{
								searchSQL += " AND (AgncyCity ='" + cbosearchCity.getSelectedItem().toString() + "')";
							}
							if (cbosearchProvince.getSelectedItem().toString() != "--Select a Province--")
							{
								searchSQL += " AND (AgncyProv ='" + cbosearchProvince.getSelectedItem().toString() + "')";
							}
							if (cbosearchCountry.getSelectedItem().toString() != "--Select a Country--")
							{
								searchSQL += " AND (AgncyCountry ='" + cbosearchCountry.getSelectedItem().toString() + "')";
							}
							searchSQL += " ORDER BY AgncyCity";
							
							//test resulting statement
							//System.out.println(searchSQL);
							
							//refresh the Agent List based on the SQL query
							refreshAgenciesList(searchSQL);
						}
					});
				}
				{
					lblsearchCity = new teJLabel();
					pnlSearch.add(lblsearchCity);
					lblsearchCity.setText("City:");
					lblsearchCity.setBounds(14, 24, 79, 14);
				}
				{
					lblsearchProvince = new teJLabel();
					pnlSearch.add(lblsearchProvince);
					lblsearchProvince.setText("Province:");
					lblsearchProvince.setBounds(14, 54, 79, 14);
				}
				{
					cbosearchCity = new teJComboBox();
					pnlSearch.add(cbosearchCity);
					cbosearchCity.setModel(cboDefaultLoad);
					cbosearchCity.setBounds(100, 12, 209, 28);
				}
				{
					cbosearchProvince = new teJComboBox();
					pnlSearch.add(cbosearchProvince);
					cbosearchProvince.setModel(cboDefaultLoad);
					cbosearchProvince.setBounds(100, 45, 208, 28);
				}
				{
					cbosearchCountry = new teJComboBox();
					pnlSearch.add(cbosearchCountry);
					cbosearchCountry.setModel(cboDefaultLoad);
					cbosearchCountry.setBounds(100, 79, 208, 28);
				}
				{
					lblsearchCountry = new teJLabel();
					pnlSearch.add(lblsearchCountry);
					lblsearchCountry.setText("Country:");
					lblsearchCountry.setBounds(13, 88, 80, 14);
				}
				
				//load the combo boxes with the initial database information:
				refreshDropDownBoxes();
			}
		} catch(Exception e) {
			e.printStackTrace();
		}
	}



	private void clearSelectionPanel()
	{
		 Component [] compsSelectPanel = pnlSelected.getComponents();
		 for (Component comp : compsSelectPanel)
		 {
			if (comp instanceof teJTextField)
			 {
				 //clear the text field
				 ((teJTextField) comp).setText("");

			 }
		 }
	}

	private void clearSearchPanel()
	{
		 Component [] compsSelectPanel = pnlSearch.getComponents();
		 for (Component comp : compsSelectPanel)
		 {
			if (comp instanceof teJComboBox)
			 {
				 ((teJComboBox) comp).setSelectedIndex(0);
			 }
		 }
	}
	
	private void refreshDropDownBoxes()
	{
		//create a string ArrayList for loading the search cities, then create the comboboxmodel
		ArrayList<String> searchCityAr = genericAgency.loadCities();
		String[] stringSearchCityAr = searchCityAr.toArray(new String[searchCityAr.size()]);
		ComboBoxModel cbosearchCityModel = 
			new DefaultComboBoxModel(stringSearchCityAr);

		//create a string ArrayList for loading the provinces, then create the comboboxmodel
		ArrayList<String> searchProvAr = genericAgency.loadProvinces();
		String[] stringSearchProvAr = searchProvAr.toArray(new String[searchProvAr.size()]);
		ComboBoxModel cbosearchProvModel = 
			new DefaultComboBoxModel(stringSearchProvAr);
		
		//create a string ArrayList for loading the country, then create the comboboxmodel
		ArrayList<String> searchCountryAr = genericAgency.loadCountries();
		String[] stringSearchCountryAr = searchCountryAr.toArray(new String[searchCountryAr.size()]);
		ComboBoxModel cbosearchCountryModel = 
			new DefaultComboBoxModel(stringSearchCountryAr);
		
		//populate the combo boxes
		cbosearchCity.setModel(cbosearchCityModel);
		cbosearchProvince.setModel(cbosearchProvModel);
		cbosearchCountry.setModel(cbosearchCountryModel);
	}
	
	//if no SQL search statement is passed through as a parameter,
	//the following refreshAgenciesList method finds all Agencies in the DB
	private void refreshAgenciesList()
	{
		ArrayList<Agencies> newAgenciesArrayList = genericAgency.agenciesAr("SELECT * FROM agencies ORDER BY AgncyCity");
		Agencies[] newAllAgencies = genericAgency.createAgencyArray(newAgenciesArrayList);
		lstAll.clearSelection();
		
		//change colour of text to dark, dark brown #2b2003, rgb 43,31,2
		lstAll.setForeground(new java.awt.Color(43,31,2));
				
		//reset the colour of the selection background
		lstAll.setSelectionBackground(new java.awt.Color(2,234,231));
		//set focusable back to true
		lstAll.setFocusable(true);
		
		ListModel newLstAllModel = 
			new DefaultComboBoxModel(newAllAgencies);
		lstAll.setModel(newLstAllModel);
	}
	
	//overload the method refreshAgenciesList to pass through a select parameter.
	//If no parameter passed through, the Select * From agencies is used
	private void refreshAgenciesList(String sqlSearch)
	{
		ArrayList<Agencies> newAgenciesArrayList = genericAgency.agenciesAr(sqlSearch);
		Agencies[] newAllAgencies = genericAgency.createAgencyArray(newAgenciesArrayList);
		lstAll.clearSelection();
		
		//change colour of text to dark, dark brown #2b2003, rgb 43,31,2
		lstAll.setForeground(new java.awt.Color(43,31,2));
				
		//reset the colour of the selection background
		lstAll.setSelectionBackground(new java.awt.Color(2,234,231));
		//set focusable back to true
		lstAll.setFocusable(true);
		
		ListModel newLstAllModel = 
			new DefaultComboBoxModel(newAllAgencies);
		lstAll.setModel(newLstAllModel);	
	}
	
	private boolean validateAgencyForm()
	{
		boolean result = true;
		ArrayList<String> errMsg = new ArrayList<String>();
		
		//testing address field:
		//if the address field is empty
		if (txtAddress.getText().equals(""))
		{
			errMsg.add("An address must be supplied.");
			result = false;
		}
		else if (!Validate.genericText(txtAddress.getText()))
		{
			errMsg.add("The address field can't contain a semicolon (;) or double dash (--).");
			result = false;
		}
		
		//testing city field:
		//if the city field is empty
		if (txtCity.getText().equals(""))
		{
			errMsg.add("A city must be supplied.");
			result = false;
		}
		//if the first name isn't valid text
		else if (!Validate.genericText(txtCity.getText()))
		{
			errMsg.add("The city field can't contain a semicolon (;) or double dash (--).");
			result = false;
		}
		
		//testing province field:
		//if the province field is empty
		if (txtProvince.getText().equals(""))
		{
			errMsg.add("A province/state must be supplied.");
			result = false;
		}
		//if the province isn't ISO valid
		else if (!Validate.isValidISOCode(txtProvince.getText()))
		{
			errMsg.add("The province/state field must be exactly 2 characters, uppercase. Ex. 'AB'.");
			result = false;
		}
		
		//testing postal code field:
		//if the postal code field is empty
		if (txtPostal.getText().equals(""))
		{
			errMsg.add("A postal/zip code must be supplied.");
			result = false;
		}
		//if the province isn't ISO valid
		else if (!Validate.isValidPostalZip(txtPostal.getText()))
		{
			errMsg.add("The postal/zip code field must be in one of the following formats: A#A #A#, ##### or #####-####.");
			result = false;
		}
		
		//testing country field:
		//if the country field is empty
		if (txtCountry.getText().equals(""))
		{
			errMsg.add("A country must be supplied.");
			result = false;
		}
		//if the first name isn't valid text
		else if (!Validate.genericText(txtCountry.getText()))
		{
			errMsg.add("The country field can't contain a semicolon (;) or double dash (--).");
			result = false;
		}
		
		//testing phone number field:
		//if the phone number field is empty
		if (txtAgtBusPhone.getText().equals(""))
		{
			errMsg.add("A phone number must be supplied.");
			result = false;
		}
		//if the last name isn't valid text

		else if (!Validate.isValidPhoneFax(txtAgtBusPhone.getText().replaceAll("[^0-9]", "")))
		{
			errMsg.add("The phone number must be 10 digits, no special characters.");
			result = false;
		}
		
		//testing fax number field:
		//if the fax number field is empty
		if (txtFax.getText().equals(""))
		{
			errMsg.add("A fax number must be supplied.");
			result = false;
		}
		//if the last name isn't valid text

		else if (!Validate.isValidPhoneFax(txtFax.getText().replaceAll("[^0-9]", "")))
		{
			errMsg.add("The fax number must be 10 digits, no special characters.");
			result = false;
		}
		
		if (result == false)
		{
			//create an errorMsg Array to populate the lstAll list		
			int lengthOfErrMsg = errMsg.size();
			String [] errorArray = new String[lengthOfErrMsg];
			for (int e = 0; e <lengthOfErrMsg; e++)
			{
				errorArray[e] = errMsg.get(e);
			}
			
			//clear the lstAll
			lstAll.clearSelection();
			
			//change colour of text to red #c62E04, rgb 198,42,3
			lstAll.setForeground(new java.awt.Color(198,42,3));

			//set the selection colour to the background so 
			//it doesn't look like anything's getting selected
			lstAll.setSelectionBackground(lstAll.getBackground());
			//set focusable to false
			lstAll.setFocusable(false);
			
			//reload the list box
			ListModel newLstAllModel = 
				new DefaultComboBoxModel(errorArray);
			lstAll.setModel(newLstAllModel);
		}
		
		return result;
	}
}
